package com.supertimetable.tools;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by ooyhao on 2017/12/5.
 */

public class StreamUtil {
    public static String InputStreamToString(InputStream inputStream) throws IOException {
        String content = null;

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int len = -1;
        byte [] buffer = new byte[1024];
        while((len = inputStream.read(buffer))!=-1){
            baos.write(buffer,0,len);
        }
        inputStream.close();
        content = new String(baos.toByteArray());

        return content;
    }
}
